import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-newdetail',
  templateUrl: './newdetail.component.html',
  styleUrls: ['./newdetail.component.css']
})
export class NewdetailComponent implements OnInit {
  public id: string;
  public id1: string;
  constructor(public router: ActivatedRoute) { }

  ngOnInit() {
    // console.log(this.router.queryParams._value.id);
    //  this.router.params获取动态路由传过来的值
    //  是一个rxjs对象
    this.router.params.subscribe(value => this.id = value.id);
    //  console.log(typeof this.id);
    this.router.queryParams.subscribe(value => {
      // console.log(value);
      this.id1 = value.id;
    });
    console.log(this.id1);
  }

}
